#ifndef DEFS_H
#define DEFS_H

#include "types.h"
#include "param.h"
#include "memlayout.h"
#include "riscv.h"
#include "spinlock.h"
#include <stdarg.h> 

//kalloc.c:
void *alloc_page(void);
void free_page(void *);
int count_free_pages();
void kinit(void);

//vm.c:
pagetable_t kvmmake(void);
void kvmmap(pagetable_t, uint64, uint64, uint64, int);
void kvminit(void);
void kvminithart(void);
pte_t *walk(pagetable_t, uint64, int);
int mappages(pagetable_t, uint64, uint64, uint64, int);
uint64 walkaddr(pagetable_t, uint64);
void destroy_pagetable(pagetable_t);
void trap_handler(void);


//test.c:
void test_physical_memory(void);
void test_pagetable(void);
void test_virtual_memory(void);

//spinlock.c:
void initlock(struct spinlock *, char *);
void acquire(struct spinlock *);
void release(struct spinlock *);
int holding(struct spinlock *);

//uart.c、lib.c:
void panic(const char *fmt, ...);
void uart_putc(int c);  
void memset(void *, int, uint64);
void memmove(void *, void *, uint64);

//printf.c:
int printf(const char *fmt, ...);
int sprintf(char *buf, const char *fmt, ...);

#endif
    